﻿using System;
using MoreEPG.Helper;

namespace MoreEPG.ViewModel
{
   
    public class ViewModelLocator
    {
        /// <summary>
        /// Initializes a new instance of the ViewModelLocator class.
        /// </summary>
        public ViewModelLocator()
        {
            CreateMainViewModel();
        }


        /// <summary>
        /// Cleans up all the resources.
        /// </summary>
        public static void Cleanup()
        {
            ClearMainViewModel();
            ClearSettingsViewModel();
            ClearCustomDialogBoxViewModel();
            ClearAboutViewModel();
            ClearMCToolsModel();
            ClearSortModel();
            ClearWelcomeModel();
            ClearDataSourceModel();
            ClearChannelConfigModel();
            ClearChannelsViewModel();
        }


        #region MainViewModel

        private static MainViewModel _main;

        /// <summary>
        /// Gets the Main property.
        /// </summary>
        public static MainViewModel MainStatic
        {
            get
            {
                if (_main == null)
                {
                    CreateMainViewModel();
                }

                return _main;
            }
        }

        /// <summary>
        /// Gets the Main property.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
            "CA1822:MarkMembersAsStatic",
            Justification = "This non-static member is needed for data binding purposes.")]
        public MainViewModel Main
        {
            get
            {
                return MainStatic;
            }
        }

        /// <summary>
        /// Provides a deterministic way to delete the Main property.
        /// </summary>
        public static void ClearMainViewModel()
        {
            _main.Cleanup();
            _main = null;
        }

        /// <summary>
        /// Provides a deterministic way to create the Main property.
        /// </summary>
        public static void CreateMainViewModel()
        {
            if (_main == null)
            {
                _main = new MainViewModel();
            }
        }

        #endregion
        
        #region AboutViewModel

        private static AboutViewModel _About;

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        public static AboutViewModel AboutStatic
        {
            get
            {
                if (_About == null)
                {
                    CreateAboutViewModel();
                }

                return _About;
            }
        }

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
            "CA1822:MarkMembersAsStatic",
            Justification = "This non-static member is needed for data binding purposes.")]
        public AboutViewModel About
        {
            get
            {
                return AboutStatic;
            }
        }

        /// <summary>
        /// Provides a deterministic way to delete the ViewModelPropertyName property.
        /// </summary>
        public static void ClearAboutViewModel()
        {
            if (_About != null)
            {
                _About.Cleanup();
                _About = null;
            }
        }

        /// <summary>
        /// Provides a deterministic way to create the ViewModelPropertyName property.
        /// </summary>
        public static void CreateAboutViewModel()
        {
            if (_About == null)
            {
                _About = new AboutViewModel();
            }
        }

        #endregion

        #region SettingsViewModel

        private static SettingsViewModel _Settings;

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        public static SettingsViewModel SettingsStatic
        {
            get
            {
                if (_Settings == null)
                {
                    CreateViewModelPropertyName();
                }

                return _Settings;
            }
        }

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
            "CA1822:MarkMembersAsStatic",
            Justification = "This non-static member is needed for data binding purposes.")]
        public SettingsViewModel Settings
        {
            get
            {
                return SettingsStatic;
            }
        }

        /// <summary>
        /// Provides a deterministic way to delete the ViewModelPropertyName property.
        /// </summary>
        public static void ClearSettingsViewModel()
        {
            if (_Settings != null)
            {
                _Settings.Cleanup();
                _Settings = null;
            }
        }

        /// <summary>
        /// Provides a deterministic way to create the ViewModelPropertyName property.
        /// </summary>
        public static void CreateViewModelPropertyName()
        {
            if (_Settings == null)
            {
                _Settings = new SettingsViewModel();
            }
        }

        #endregion

        #region CustomDialogBoxViewModel

        private static CustomDialogBoxViewModel _CustomDialogBox;

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        public static CustomDialogBoxViewModel CustomDialogBoxStatic
        {
            get
            {
                if (_CustomDialogBox == null)
                {
                    CreateCustomDialogBoxViewModel();
                }

                return _CustomDialogBox;
            }
        }

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
            "CA1822:MarkMembersAsStatic",
            Justification = "This non-static member is needed for data binding purposes.")]
        public CustomDialogBoxViewModel CustomDialogBox
        {
            get
            {
                return CustomDialogBoxStatic;
            }
        }

        /// <summary>
        /// Provides a deterministic way to delete the ViewModelPropertyName property.
        /// </summary>
        public static void ClearCustomDialogBoxViewModel()
        {
            if (_CustomDialogBox != null)
            {
                _CustomDialogBox.Cleanup();
                _CustomDialogBox = null;
            }
        }

        /// <summary>
        /// Provides a deterministic way to create the ViewModelPropertyName property.
        /// </summary>
        public static void CreateCustomDialogBoxViewModel()
        {
            if (_CustomDialogBox == null)
            {
                _CustomDialogBox = new CustomDialogBoxViewModel();
            }
        }

        #endregion

        #region MCToolsViewModel

        //
        // MCToolsModel
        //
        private static MCToolsViewModel _MCToolsModel;

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        public static MCToolsViewModel MCToolsModelStatic
        {
            get
            {
                if (_MCToolsModel == null)
                {
                    CreateMCToolsModel();
                }

                return _MCToolsModel;
            }
        }

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
            "CA1822:MarkMembersAsStatic",
            Justification = "This non-static member is needed for data binding purposes.")]
        public MCToolsViewModel MCToolsModel
        {
            get
            {
                return MCToolsModelStatic;
            }
        }

        /// <summary>
        /// Provides a deterministic way to delete the ViewModelPropertyName property.
        /// </summary>
        public static void ClearMCToolsModel()
        {
            if (_MCToolsModel != null)
            {
                _MCToolsModel.Cleanup();
                _MCToolsModel = null;
            }
        }

        /// <summary>
        /// Provides a deterministic way to create the ViewModelPropertyName property.
        /// </summary>
        public static void CreateMCToolsModel()
        {
            if (_MCToolsModel == null)
            {
                _MCToolsModel = new MCToolsViewModel();
            }
        }

        #endregion
        
        #region SortViewModel

        //
        // MCToolsModel
        //
        private static SortViewModel _SortModel;

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        public static SortViewModel SortModelStatic
        {
            get
            {
                if (_SortModel == null)
                {
                    CreateSortModel();
                }

                return _SortModel;
            }
        }

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
            "CA1822:MarkMembersAsStatic",
            Justification = "This non-static member is needed for data binding purposes.")]
        public SortViewModel SortModel
        {
            get
            {
                return SortModelStatic;
            }
        }

        /// <summary>
        /// Provides a deterministic way to delete the ViewModelPropertyName property.
        /// </summary>
        public static void ClearSortModel()
        {
            if (_SortModel != null)
            {
                _SortModel.Cleanup();
                _SortModel = null;
            }
        }

        /// <summary>
        /// Provides a deterministic way to create the ViewModelPropertyName property.
        /// </summary>
        public static void CreateSortModel()
        {
            if (_SortModel == null)
            {
                _SortModel = new SortViewModel();
            }
        }

        #endregion
        
        #region WelcomeViewModel

        //
        // MCToolsModel
        //
        private static WelcomeViewModel _WelcomeModel;

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        public static WelcomeViewModel WelcomeModelStatic
        {
            get
            {
                if (_MCToolsModel == null)
                {
                    CreateWelcomeModel();
                }

                return _WelcomeModel;
            }
        }

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
            "CA1822:MarkMembersAsStatic",
            Justification = "This non-static member is needed for data binding purposes.")]
        public WelcomeViewModel WelcomeModel
        {
            get
            {
                return WelcomeModelStatic;
            }
        }

        /// <summary>
        /// Provides a deterministic way to delete the ViewModelPropertyName property.
        /// </summary>
        public static void ClearWelcomeModel()
        {
            if (_WelcomeModel != null)
            {
                _WelcomeModel.Cleanup();
                _WelcomeModel = null;
            }
        }

        /// <summary>
        /// Provides a deterministic way to create the ViewModelPropertyName property.
        /// </summary>
        public static void CreateWelcomeModel()
        {
            if (_WelcomeModel == null)
            {
                _WelcomeModel = new WelcomeViewModel();
            }
        }

        #endregion

        #region DataSourceViewModel

        //
        // MCToolsModel
        //
        private static DataSourceViewModel _DataSourceModel;

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        public static DataSourceViewModel DataSourceModelStatic
        {
            get
            {
                if (_DataSourceModel == null)
                {
                    CreateDataSourceModel();
                }

                return _DataSourceModel;
            }
        }

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
            "CA1822:MarkMembersAsStatic",
            Justification = "This non-static member is needed for data binding purposes.")]
        public DataSourceViewModel DataSourceModel
        {
            get
            {
                return DataSourceModelStatic;
            }
        }

        /// <summary>
        /// Provides a deterministic way to delete the ViewModelPropertyName property.
        /// </summary>
        public static void ClearDataSourceModel()
        {
            if (_DataSourceModel != null)
            {
                _DataSourceModel.Cleanup();
                _DataSourceModel = null;
            }
        }

        /// <summary>
        /// Provides a deterministic way to create the ViewModelPropertyName property.
        /// </summary>
        public static void CreateDataSourceModel()
        {
            if (_DataSourceModel == null)
            {
                _DataSourceModel = new DataSourceViewModel();
            }
        }

        #endregion
        
        #region ChannelConfigModel

        //
        // MCToolsModel
        //
        private static ChannelConfigModel _ChannelConfig;

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        public static ChannelConfigModel ChannelConfigStatic
        {
            get
            {
                if (_ChannelConfig == null)
                {
                    CreateChannelConfig();
                }

                return _ChannelConfig;
            }
        }

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
            "CA1822:MarkMembersAsStatic",
            Justification = "This non-static member is needed for data binding purposes.")]
        public ChannelConfigModel ChannelConfig
        {
            get
            {
                return ChannelConfigStatic;
            }
        }

        /// <summary>
        /// Provides a deterministic way to delete the ViewModelPropertyName property.
        /// </summary>
        public static void ClearChannelConfigModel()
        {
            if (_ChannelConfig != null)
            {
                _ChannelConfig.Cleanup();
                _ChannelConfig = null;
            }
        }

        /// <summary>
        /// Provides a deterministic way to create the ViewModelPropertyName property.
        /// </summary>
        public static void CreateChannelConfig()
        {
            if (_ChannelConfig == null)
            {
                _ChannelConfig = new ChannelConfigModel();
            }
        }

        #endregion

        #region ChannelsViewModel

        //
        // MCToolsModel
        //
        private static ChannelsViewModel _ChannelsViewModel;

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        public static ChannelsViewModel ChannelsViewModelStatic
        {
            get
            {
                if (_ChannelsViewModel == null)
                {
                    CreateChannelsViewModel();
                }

                return _ChannelsViewModel;
            }
        }

        /// <summary>
        /// Gets the ViewModelPropertyName property.
        /// </summary>
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
            "CA1822:MarkMembersAsStatic",
            Justification = "This non-static member is needed for data binding purposes.")]
        public ChannelsViewModel ChannelsViewModel
        {
            get
            {
                return ChannelsViewModelStatic;
            }
        }

        /// <summary>
        /// Provides a deterministic way to delete the ViewModelPropertyName property.
        /// </summary>
        public static void ClearChannelsViewModel()
        {
            if (_ChannelsViewModel != null)
            {
                _ChannelsViewModel.Cleanup();
                _ChannelsViewModel = null;
            }
        }

        /// <summary>
        /// Provides a deterministic way to create the ViewModelPropertyName property.
        /// </summary>
        public static void CreateChannelsViewModel()
        {
            if (_ChannelConfig == null)
            {
                _ChannelConfig = new ChannelConfigModel();
            }
        }

        #endregion

    }
}